import "./ToolTip.scss";

export function initToolTip(viewer) {
	this._init = true;
	var frameDiv = viewer.quarkgisWidget.container
	var div = document.createElement('DIV');
	div.className = "tooltipdiv right";//

	var arrow = document.createElement('DIV');
	arrow.className = "tooltipdiv-arrow";
	div.appendChild(arrow);

	var title = document.createElement('DIV');
	title.className = "tooltipdiv-inner";
	div.appendChild(title);

	this._div = div;
	this._title = title;

	frameDiv.appendChild(div);
}
export function setToolTipVisible(visible){
	if(this._init){
		this._div.style.display = visible ? 'block' : 'none';
	}
}
/**
 * 显示在屏幕上
 * @param position 定位
 * @param markerInfo marker的信息
 */
export function infoToolTip(markerInfo) {
	if(markerInfo && this._init) {
		this.setToolTipVisible(true);
		this._title.innerHTML = markerInfo.name;
	}
}
export function positionToolTip(position) {
	if (position && this._init) {
		this._div.style.left = position.x + 10 + "px";
		this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
	}
}
